package pattern.single;
/**
 * 单子模式
 * @author Alvin
 */
public class Single {	
		private static Single single = null;
		private void Single(){	
			//构造器必须私有
		}
		//如果不涉及并发可以不加锁
		public static synchronized Single getSingle(){
			if(single == null)
				single = new Single();
			return single;
		}
		
		public void say(){
			System.out.println("Hi,onle me at here!");
		}
		
		public static void main(String args[]){
			Single s = new Single();
			s.say();
	}
}
